package top.zhangjianyong.tools.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.function.Consumer;

/**
 * @author ： zhangjianyong
 * @date ： 2022/8/1 9:01 AM
 */
@Data
public abstract class BaseBill {

    public BaseBill() {
        this.totalIncome = BigDecimal.ZERO;
        this.totalPay = BigDecimal.ZERO;
        this.wxIncome = BigDecimal.ZERO;
        this.wxPay = BigDecimal.ZERO;
        this.aliIncome = BigDecimal.ZERO;
        this.aliPay = BigDecimal.ZERO;
    }

    private BigDecimal totalIncome;
    private BigDecimal totalPay;
    private BigDecimal wxIncome;
    private BigDecimal wxPay;
    private BigDecimal aliIncome;
    private BigDecimal aliPay;


    /**
     * 累加金额
     *
     * @param amt
     * @param platform
     */
    public void add(String inOrOut, BigDecimal amt, String platform) {

        switch (inOrOut) {
            case "收入":
                totalIncome = totalIncome.add(amt);
                addIncome(amt, platform);
                break;
            case "支出":
                totalPay = totalPay.add(amt);
                addPay(amt, platform);
                break;
            default:
                throw new RuntimeException("未知收支状态");
        }
    }

    private void addIncome(BigDecimal amt, String platform) {
        switch (platform) {
            case "微信":
                this.wxIncome = this.wxIncome.add(amt);
                break;
            case "支付宝":
                this.aliIncome = this.aliIncome.add(amt);
                break;
            default:
                throw new RuntimeException("平台错误");
        }
    }

    private void addPay(BigDecimal amt, String platform) {
        switch (platform) {
            case "微信":
                this.wxPay = this.wxPay.add(amt);
                break;
            case "支付宝":
                this.aliPay = this.aliPay.add(amt);
                break;
            default:
                throw new RuntimeException("平台错误");
        }
    }


}
